package BlackJack.Control
{
	import BlackJack.Model.Events.LobbyEvent;
	import BlackJack.Model.Events.TableEvent;
	import BlackJack.View.Lobby;
	import BlackJack.View.Table;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	import org.robotlegs.mvcs.Command;

	public class TableCommand extends Command
	{
		[Inject]
		public var event:TableEvent;

		override public function execute():void
		{
			main.debug.MESSAGE(this + '\t' + event.type);
			switch (event.type)
			{
				case TableEvent.Exit:
				{
					socket.C2S_TableExit();
					break;
				}
				case TableEvent.Bet:
				{
					socket.C2S_PlayerBet(table.TotalBet);
					break;
				}
				case TableEvent.Charge:
					break;
				case TableEvent.Rank:
				{
					var request:URLRequest = new URLRequest('http://golden.goldengame.com.tw/rank/rank_bonus.php?type=5');
					navigateToURL(request, '_blank');
					break;
				}
				case TableEvent.Smile:
					break;
				case TableEvent.SoundOff:
					break;
				case TableEvent.SoundOn:
					break;
			}
		}

		public function get main():BlackJackMain
		{
			return contextView as BlackJackMain;
		}

		public function get socket():FGS12Processer
		{
			return main.socket;
		}

		public function get lobby():Lobby
		{
			return main.lobby;
		}

		public function get table():Table
		{
			return main.table;
		}
	}
}
